package com.ms.service.module.fish.message.server;

import java.nio.ByteBuffer;
import java.util.Set;

import com.ms.service.module.fish.game.FishGame;
import com.ms.service.module.fish.game.GameUser;
import com.ms.service.module.fish.message.FishBaseMessage;

/**
 * 进入开始中的游戏113
 * @author cuiwm
 */
public class GameInfoMessage extends FishBaseMessage {
	
    private GameUser user;
    
    public GameInfoMessage(GameUser user) {
    	this.setUser(user);
	}

	public GameUser getUser() {
		return user;
	}

	public void setUser(GameUser user) {
		this.user = user;
	}

	@Override
	public void writeBody(ByteBuffer buf) {
		FishGame game = user.getGame();
		buf.putInt(game.getStagId());
		long startTime = game.getStartTime();
		long now = System.currentTimeMillis();
		long dura = (now - startTime);
		buf.putInt((int) dura);
		
		Set<Integer> fishs = game.getFishs();
		buf.putInt(fishs.size());
		for(Integer scr:fishs) {
			buf.putInt(scr);
		}
		
		buf.put((byte) (game.haveBoss()?1:0));
		buf.put((byte) (game.isBossShow()?1:0));
		buf.put((byte) (game.isBossDead()?1:0));
		
	}


}